<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
class Preach extends Controller
{
    // 宣讲管理页
    public function index()
    {
        $res = Db::table('preach')
                ->alias('a')
                ->join('company c','c.company_id = a.company_id')
                ->where('preach_status',0)
                ->order('preach_id desc')
                ->select();
        // dump($res);
        // exit;
        $this->assign('res',$res);
        return $this->fetch();
    }
    // 宣讲详情页
    public function xjdetails($preach_id)
    {
        $res=Db::table('preach p')
        ->join('company c','c.company_id=p.company_id')
        ->where('preach_id',$preach_id)
        ->where('preach_status',0)
        ->select();
        $this->assign("res",$res);
         // dump($res);
           // die;
        return $this->fetch();
    }
    // 删除职位
    public function xjdelete($preach_id)
    {
      $data = [
          'preach_status'=>1,
        ];
        $res = Db::table('preach')->where('preach_id',$preach_id)->update($data);
        if($res){
            return $this->success('删除成功','preach/index');
        }
        else{
          return $this->error('删除失败');
        }
    }
}
